#pragma once
#include <functional>

typedef std::function<void(void *pItem)> RELEASELISTENER;
class CLog
{
public:
	CLog();
	CLog::CLog(const CLog & scr);
	~CLog();

public:
	int AddRef();
	int Release();

public:
	int setLog(void *pFrom, int nLevel, char *pszText);
	inline int getLevel() { return m_nLevel; };
	inline char * getMessage() { return m_szMessage; };
	inline time_t & getTime() { return m_time; };
	void SetReleaseListener(RELEASELISTENER listener);
	void lock();
	void unlock();

public:
	void *m_pFrom;;

private:
	int m_nLevel;
	time_t m_time;
	char m_szMessage[1024];
	int m_nMessageLen;
	unsigned int m_nRef;
	CRITICAL_SECTION m_cs;
	RELEASELISTENER m_fReleaseListener;
};

